/*     */ package com.qmsk.business.store.goodsStock.controller;
/*     */ 
/*     */ import com.qmsk.business.store.goodsStock.dao.GoodsStockDao;
/*     */ import com.utils.basic.MapUtils;
/*     */ import com.utils.gson.in.ParserDataSetJson;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.jdbc.connection.DbConnection;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import java.io.IOException;
/*     */ import java.util.HashMap;
/*     */ import java.util.Map;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"/goodsStock"})
/*     */ public class GoodsStockController
/*     */ {
/*  35 */   private static final Logger logger = Logger.getLogger(GoodsStockController.class);
/*     */ 
/*     */   @Autowired
/*     */   private GoodsStockDao dao;
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/opt/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOptShopId(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") String shopId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  55 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try
/*     */     {
/*  58 */       Map params = new HashMap();
/*  59 */       MapUtils.addToMap(params, "shopId", shopId);
/*  60 */       MapUtils.addToMap(params, "lrgId", 
/*  61 */         RequestUtils.getLong(request, "lrgId"));
/*  62 */       MapUtils.addToMap(params, "medID", 
/*  63 */         RequestUtils.getLong(request, "medID"));
/*  64 */       MapUtils.addToMap(params, "smlID", 
/*  65 */         RequestUtils.getLong(request, "smlID"));
/*  66 */       MapUtils.addToMap(params, "ordAttrID", 
/*  67 */         RequestUtils.getLong(request, "ordAttrID"));
/*  68 */       MapUtils.addToMap(params, "supID", 
/*  69 */         RequestUtils.getLong(request, "supID"));
/*  70 */       MapUtils.addToMap(params, "houseID", 
/*  71 */         RequestUtils.getLong(request, "houseID"));
/*  72 */       MapUtils.addToMap(params, "status", 
/*  73 */         RequestUtils.getInt(request, "status"));
/*  74 */       MapUtils.addToMap(params, "bom", 
/*  75 */         RequestUtils.getInt(request, "bom"));
/*  76 */       MapUtils.addToMap(params, "useGR", 
/*  77 */         RequestUtils.getInt(request, "useGR"));
/*  78 */       MapUtils.addPercentToMap(params, "code", 
/*  79 */         RequestUtils.getString(request, "code"));
/*  80 */       MapUtils.addPercentToMap(params, "name", 
/*  81 */         RequestUtils.getString(request, "name"));
/*  82 */       MapUtils.addPercentToMap(params, "enName", 
/*  83 */         RequestUtils.getString(request, "enName"));
/*  84 */       MapUtils.addToMap(params, "barCode", 
/*  85 */         RequestUtils.getString(request, "barCode"));
/*  86 */       MapUtils.addToMap(params, "srhCode", 
/*  87 */         RequestUtils.getString(request, "srhCode"));
/*     */ 
/*  90 */       GsonEbRst gsonEbRst = this.dao.getPageOfHouseId(params, nPageIdx, 
/*  91 */         nPageSize);
/*  92 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/*  94 */       logger.error(e);
/*  95 */       ResponseUtils.setErrorMsgResponse(
/*  96 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getHouseId(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") String shopId)
/*     */   {
/*     */     try
/*     */     {
/* 113 */       Long houseId = this.dao.getHouseId(shopId);
/* 114 */       ResponseUtils.setResponseResult(houseId, response);
/*     */     } catch (Exception e) {
/* 116 */       logger.error(e);
/* 117 */       ResponseUtils.setErrorMsgResponse(
/* 118 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/hId/{hId}/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListofHouseId(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") String shopId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize, @PathVariable("hId") Long hId)
/*     */   {
/* 129 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/* 131 */       Map params = new HashMap();
/* 132 */       MapUtils.addToMap(params, "hId", hId);
/* 133 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(params, nPageIdx, nPageSize);
/* 134 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/* 136 */       logger.error(e);
/* 137 */       ResponseUtils.setErrorMsgResponse(
/* 138 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/{hId}/{gId}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListofHIdAndGId(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") String shopId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize, @PathVariable("hId") Long hId, @PathVariable("gId") Long gId)
/*     */   {
/* 149 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/* 151 */       Map params = new HashMap();
/* 152 */       MapUtils.addToMap(params, "hId", hId);
/* 153 */       MapUtils.addToMap(params, "gId", gId);
/* 154 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(params, nPageIdx, nPageSize);
/* 155 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/* 157 */       logger.error(e);
/* 158 */       ResponseUtils.setErrorMsgResponse(
/* 159 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"insert/shopId/{shopId}/initial/{storeId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insertInitial(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId, @PathVariable("storeId") Long storeId)
/*     */     throws IOException
/*     */   {
/*     */     try
/*     */     {
/* 181 */       int nResult = 0;
/* 182 */       nResult = this.dao.insertInitial(storeId);
/* 183 */       if (nResult > 0)
/* 184 */         DbConnection.commit();
/*     */       else {
/* 186 */         DbConnection.rollback();
/*     */       }
/*     */ 
/* 192 */       ResponseUtils.setSuccessResponse(response);
/*     */     }
/*     */     catch (Exception e) {
/* 195 */       DbConnection.rollback();
/* 196 */       logger.error(e);
/* 197 */       ResponseUtils.setErrorMsgResponse(
/* 198 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 199 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"insert/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insert(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Integer shopId)
/*     */     throws IOException
/*     */   {
/*     */     try
/*     */     {
/* 219 */       int nResult = 0;
/* 220 */       String sData = RequestUtils.getStringOfData(request);
/* 221 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/* 222 */       nResult = this.dao.applyUpdates(p);
/* 223 */       if (nResult > 0)
/* 224 */         DbConnection.commit();
/*     */       else {
/* 226 */         DbConnection.rollback();
/*     */       }
/* 228 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 229 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 230 */         response);
/*     */     } catch (Exception e) {
/* 232 */       DbConnection.rollback();
/* 233 */       logger.error(e);
/* 234 */       ResponseUtils.setErrorMsgResponse(
/* 235 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 236 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"del/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void delete(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 249 */     String sJson = RequestUtils.getStringOfId(request);
/*     */     try {
/* 251 */       int nResult = this.dao.deleteList(sJson);
/* 252 */       if (nResult > 0)
/* 253 */         DbConnection.commit();
/*     */       else {
/* 255 */         DbConnection.rollback();
/*     */       }
/* 257 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 258 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 259 */         response);
/*     */     }
/*     */     catch (Exception e) {
/* 262 */       DbConnection.rollback();
/* 263 */       logger.error(e);
/* 264 */       ResponseUtils.setErrorMsgResponse(
/* 265 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 266 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"edit/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void update(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Integer shopId)
/*     */   {
/*     */     try
/*     */     {
/* 284 */       int nResult = 0;
/* 285 */       String sData = RequestUtils.getStringOfData(request);
/* 286 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/* 287 */       nResult = this.dao.applyUpdates(p);
/* 288 */       if (nResult > 0)
/* 289 */         DbConnection.commit();
/*     */       else {
/* 291 */         DbConnection.rollback();
/*     */       }
/* 293 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 294 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 295 */         response);
/*     */     } catch (Exception e) {
/* 297 */       logger.error(e);
/* 298 */       DbConnection.rollback();
/* 299 */       ResponseUtils.setErrorMsgResponse(
/* 300 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 301 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.store.goodsStock.controller.GoodsStockController
 * JD-Core Version:    0.5.3
 */